package com.zzyl.serve.mapper.member;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzyl.serve.domain.member.Reservation;
import com.zzyl.serve.vo.member.ReservationCountBytimeVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 预约信息Mapper接口
 * 
 * @author ruoyi
 * @date 2025-03-12
 */
@Mapper
public interface ReservationMapper extends BaseMapper<Reservation>
{


   @Update("update reservation set status = #{status} where id = #{id}")
    int updateReservationStatusById(Reservation entity);

    /**
     * 查询预约信息列表
     * 
     * @param reservation 预约信息
     * @return 预约信息集合
     */
    public List<Reservation> selectReservationList(Reservation reservation);

    /**
     * 新增预约信息
     * 
     * @param reservation 预约信息
     * @return 结果
     */
    public int insertReservation(Reservation reservation);






    //查询当前以及和以后一天的预计次数,不为2的
    @Select("   select time, 6 - count(*) as count from reservation\n" +
            "        where time between #{starTime} and #{endTime}\n" +
            "          and status != 2 group by time;")
    List<ReservationCountBytimeVo> getCountByTime(@Param("starTime") LocalDateTime starTime,@Param("endTime") LocalDateTime endTime);

}
